package servlet;

import el.Monster;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(urlPatterns = {"/queryServlet"})
public class QueryServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ArrayList<Monster> List = new ArrayList<>();
        List.add(new Monster(100,"牛魔王","芭蕉扇"));
        List.add(new Monster(200,"狐狸精","美人计"));
        List.add(new Monster(300,"白骨精","吃骨头"));

        req.setAttribute("monsters",List);
        req.getRequestDispatcher("/homework/query.jsp").forward(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
